//
//  YLBaseViewController.m
//  TheTenthAnniversaryOfMobileUnion
//
//  Created by kuangbiao on 2019/1/24.
//  Copyright © 2019 kuangbiao. All rights reserved.
//

#import "YLBaseViewController.h"
#import "Header.h"
#import "YLSettingViewController.h"

@interface YLBaseViewController ()

@property (nonatomic, strong) UIImageView *logoImageView;//底部logo

@end

@implementation YLBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initbaseView];

}

- (void)initbaseView{
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.logoImageView];
    [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.bottom.equalTo(self.view.mas_bottom).offset(-65);
    }];
    self.hiddenLogo = YES;
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    rightBtn.frame = CGRectMake(0, 2, 40, 40);
    [rightBtn setImage:[UIImage imageNamed:@"set black"] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(setBtnClickAction) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightBaritem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItem = rightBaritem;
}

- (UIImageView *)logoImageView{
    if(!_logoImageView){
        _logoImageView = [[UIImageView alloc] init];
        _logoImageView.image = [UIImage imageNamed:@"logo"];
    }
    return _logoImageView;
}

- (void)setHiddenLogo:(BOOL)hiddenLogo{
    self.logoImageView.hidden = hiddenLogo;
}

- (void)setHiddenSetBtn:(BOOL)hiddenSetBtn{
    if(hiddenSetBtn){
        self.navigationItem.rightBarButtonItem = nil;
    }
}

#pragma mark - 设置按钮点击事件
- (void)setBtnClickAction{
    YLSettingViewController *setVC = [[YLSettingViewController alloc] initWithNibName:@"YLSettingViewController" bundle:nil];
    [self.navigationController pushViewController:setVC animated:YES];
}

@end
